<extend name="common:commonNewerTemplate" />
<block name="main_content">
<style type="text/css">
	.title_label{
		font-size: 14px;
		font-family: "Open Sans","Comic Sans MS";
		vertical-align: middle;
		padding-left: 15px;
		padding-right: 5px;
	   /*  vertical-align: -moz-middle-with-baseline;
	    vertical-align: baseline; */
	}
	.title_content{
		font-size: 12px;
		font-family: "Open Sans","Comic Sans MS";
		vertical-align: middle;
		padding-left: 5px;
		padding-right: 15px;
	  /*   vertical-align: -moz-middle-with-baseline;
	    vertical-align: baseline; */
	}
	.widget-title span.title {
	    float: left;
	    padding: 9px 10px 7px 11px;
	}
</style>
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a class="tip-bottom" href="index.html" data-original-title="Go to Home">
				<i class="icon-home"></i> 首页
			</a>
			<a href="#">大客户订单</a> 
			<a href="/dealer/paperInvList">经销商发票开具</a>
			<a class="current" href="#">经销商发票预览</a>
		</div>
	</div>
	<!-- 错误提示功能 -->
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i></span>
						<h5>操作与提示</h5>
					</div>
					<div class="widget-content nopadding">
						<form novalidate="novalidate"  action="#" method="post" class="form-horizontal">
							<empty name="msg"><else />
								<div class="control-group">
									<label class="control-label">提示信息:</label>
									<label class="controls" style="color: red;padding-top: 15px;">{$msg}</label>
								</div>
							</empty>
							<div class="form-actions">
								<button id="btn_save" type="button" class="btn btn-primary">保存</button>
								<!-- <button id="btn_close" type="button" class="btn btn-danger">关闭</button> -->
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	
	
	    <volist name="lst_preview" id="invoice_head">
				<div class="row-fluid">
					<div class="span12">
						<div class="widget-box">
							<div class="widget-title ">
								<span class="icon"> <i class="icon-info-sign"></i></span>
								<span class="title">
									<span class="title_label">发票抬头:</span>
								 	<span class="title_content">{$invoice_head.invoice_name}</span>
								 	<span class="title_label">发票金额:</span>
								 	<span class="title_content">{$invoice_head.invoice_amount}</span>
								 	<span class="title_label">总商品金额(不含税):</span>
								 	<span class="title_content">{$invoice_head.sum_price}</span>
								 	<span class="title_label">总税额:</span>
								 	<span class="title_content">{$invoice_head.sum_tax}</span>
						 		</span>
							 	
							</div>
							<div class="widget-content nopadding">
								<div class="widget-content nopadding">
					            	<table id="logistics_result"  page_index="1" class="table table-bordered table-striped wi_tree_gird">
									<!-- 标题层 -->
					              		<thead>
							                <tr>
							                  <th>发票名称</th>
							                  <th>含税单价</th>
							                  <th>含税总价</th>
							                  <th>单价(不含税)</th>
							                  <th>总价(不含税)</th>
							                  <th>数量</th>
							                  <th>税额</th>
							                  <th>税率</th>
							                  <th>单位</th>
							                  <th>规格型号</th>
							                </tr>
						              	</thead>
						              	<tbody>
						              		<empty name="invoice_head['invoice_detail']">
						              			<tr class="empty-data"><td colspan="10">暂无信息</td><tr/>
					              			<else />
					              	        	<volist name="invoice_head['invoice_detail']" id="invoice_detail">
										            <tr>
										            	<td>{$invoice_detail.item_name}</td>
										            	<td>{$invoice_detail.amount}</td>
										            	<td>{$invoice_detail.invoice_amount}</td>
										            	<td>{$invoice_detail.price}</td>
										            	<td>{$invoice_detail.sum_price}</td>
										            	<td>{$invoice_detail.quantity}</td>
										            	<td>{$invoice_detail.tax}</td>
										            	<td>{$invoice_detail.tax_rate}</td>
										            	<td>{$invoice_detail.unit}</td>
										            	<td>{$invoice_detail.specification}</td>
										            </tr>
												</volist>
					              			</empty>
						              	</tbody>
				            		</table>
				          		</div>
							</div>
						</div>
					</div>
				</div>
		</volist>
	</div>

</div>
</block>

<block name="js_content">
<script src="../../../Public/js/laydate/laydate.js"></script>
<script src="/Public/js/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript">
	PreviewPage = {
		'Bind' : function(){
			 $('#btn_save').bind('click', function(){
			 	layer.confirm('确认保存?', {
				  btn: ['确认','取消'] //按钮
				}, function(index){
					layer.close(index);
					var param = {};
					param.lst_invoice = eval({$lst_invoice});
					param.oids = eval({$oids});
					$.ajax({
					  type : 'post',
					  url : '/AjaxService/center/order/paperinvsave',
					  data : param,
					  dataType : 'json',
					  async : true,
					  success : function(data) {
						  if(data.IsSuccess == 0){
							  layer.msg(data.ErrorMsg, {icon: 5});
						  }else{
							  layer.msg('操作成功', {icon: 0});
						  }
					  },
			      	  error : function(e, err_name, err_text) {
			      		layer.msg(err_text, {icon: 5});
			    	  }
					});  
				}, function(){});
			}); 
		}
	};	
	$(document).ready(function(){
		var msg = "{$msg}";
		if(msg != ''){
			layer.msg(msg, {icon: 5});
		}
		PreviewPage.Bind();
	});
</script>
</block>